home *** CD-ROM | disk | FTP | other *** search
/ Disc to the Future 2 / Disc to the Future Part II Programmer's Reference (Wayzata Technology)(6013)(1992).bin / MAC / MPW_TOOL / TOOLS / TOOLS_WI / ICON_8 / TESTS / PERMUTE.ICN < prev    next >
Text File  |  1990-03-02  |  310b  |  18 lines

  1. procedure main()
  2.    output := set()
  3.    every 1 to 2 do
  4.       every insert(output,permute("ogram"))
  5.    every write(!output)
  6. end
  7.  
  8. procedure permute(s)
  9.    local i, x, t
  10.    if s == "" then return ""
  11.    every i := 1 to *s do {
  12.       x := s[i]
  13.       t := s
  14.       t[i] := ""
  15.       suspend x || permute(t)
  16.       }
  17. end
  18.